/**
 * 
 */
package com.huarui.desktop.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.ewaf.framework.dao.impl.BaseSimpleDao;

import com.huarui.desktop.dao.DesktopMenuDao;
import com.huarui.desktop.model.DesktopMenu;

/**
 * @author peng.sunp
 *
 */
public class DesktopMenuDaoImpl extends BaseSimpleDao implements DesktopMenuDao {

	/* (non-Javadoc)
	 * @see com.huarui.desktop.dao.DesktopMenuDao#selectDesktopMenus(java.lang.Integer)
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Map<Integer,DesktopMenu> selectDesktopMenus(Integer desktopId) {
		return (Map<Integer,DesktopMenu>) getSqlMapClientTemplate().queryForMap(namespace + ".selectByDesktop",desktopId, "id");
	}

	@SuppressWarnings("unchecked")
	public List<DesktopMenu> selectSubMenus(Integer desktopId,Integer menuId) {
		HashMap<String,Integer> params=new HashMap<String,Integer>();
		params.put("desktopId", desktopId);
		params.put("menuId", menuId);
		return (List<DesktopMenu>) getSqlMapClientTemplate().queryForList(namespace + ".selectSubMenus",params);
	}
	
	public void insertDesktopMenu(DesktopMenu desktopMenu){
		getSqlMapClientTemplate().insert(namespace + ".insertDesktopMenu", desktopMenu);
	}
	
	public void deleteAllDesktopMenu(){
		getSqlMapClientTemplate().delete(namespace + ".deleteAllDesktopMenu");

	}
}
